// pages/my/my.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userName: "姓名",
    userAvatar: "",
    userAddress: "这是住址,等待获取",
    role:wx.getStorageSync('role')
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _that=this
    if(wx.getStorageSync('role')=='manager'){
      wx.request({
        url: 'http://localhost/Wx/Managerinfo',
        method:'post',
        header:{
          "Content-Type": "application/x-www-form-urlencoded"
        },
        data:{
          openid:wx.getStorageSync('openid')
        },
        success(res){
          _that.setData({
            userName:res.data.data.nickname,
            userAvatar:res.data.data.avatarUrl,
            userAddress:"社区管理员",
          })
        }
      })
    }else if(wx.getStorageSync('role')=='user'){
      wx.request({
        url: 'http://localhost/Wx/Userinfo',
        method:'post',
        header:{
          "Content-Type": "application/x-www-form-urlencoded"
        },
        data:{
          openid:wx.getStorageSync('openid')
        },
        success(res){
          console.log(res.data.data)
          _that.setData({
            userName:res.data.data.nickname,
            userAvatar:wx.getStorageSync('userDetail').avatarUrl,
            userAddress:wx.getStorageSync('userDetail').AmName+"  "+wx.getStorageSync('userDetail').BlockName
          })
        }
      })
    }
  },
  toInfo:function(){
    wx.navigateTo({
      url: '../info/info',
    })
  },
  toSetting:function(){
    wx.navigateTo({
      url: '../setting/setting',
    })
  },
  toAddMember:function(){
    wx.navigateTo({
      url:'../addMember/addMember'
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})